** Correcting variable names/labels/notes/inconsistencies for the endline student survey

* Section 1. School identification/Section 2. Student identification
********************************************************************
clear all
set more off

cd "[directory]/Clean_data"


*This was a non-baseline student at ES Gasange
replace schoolid = 503014 if schoolid == 50301421 & key == "uuid:11d02ad1-ec2f-4d92-9d34-7bcbd38e8427"
replace group_107 = 2 if schoolid == 503014 & key == "uuid:11d02ad1-ec2f-4d92-9d34-7bcbd38e8427"
replace school_name = 21 if schoolid == 503014 & key == "uuid:11d02ad1-ec2f-4d92-9d34-7bcbd38e8427"
replace first_name_200 = "XXX" if key == "uuid:11d02ad1-ec2f-4d92-9d34-7bcbd38e8427" // names removed for respondent privacy
replace family_name_200 = "XXX" if key == "uuid:11d02ad1-ec2f-4d92-9d34-7bcbd38e8427"// names removed for respondent privacy

*
la var schoolid "Please enter schoolid"

*school_loc
la var province_201 "201_Province"
la var district_201 "201_District"
la var sector_201 "201_Sector"
la var cell_201 "201_Cell"
la var village_201 "201_Village"

*Modified question notes to to match the baseline ones
notes drop school_name in 2
notes drop province_201 in 1
notes drop province_201 in 2
notes province_201: Question text: 201_Province
notes replace district_201 in 1: "Question text: 201_District"
notes drop sector_201 in 1
notes sector_201: Question text: 201_Sector
notes drop cell_201 in 2
notes replace cell_201 in 1: "Question text: 201_Cell"
notes drop village_201 in 1
notes replace village_201 in 2: "Question text: 201_Village"

la var sector "Sector where the student lives"
**********************************
la def yesnolbl 1 "Yes" 0 "No"
***************************************
*group
replace group_107 = 4 if key == "uuid:11d02ad1-ec2f-4d92-9d34-7bcbd38e8427"
la var group_107 "107_Group (whether treatment or control)"
notes group_107: 107_Group (whether treatment or control)
la var deviceid "Deviceid"
*class_dropout
replace class_dropout = 2 if key == "uuid:c93ab6c3-ebb6-44cc-9306-c32575754d5f"
replace droppeds5_404 = 1 if key == "uuid:c93ab6c3-ebb6-44cc-9306-c32575754d5f"

replace class_dropout = 2 if key == "uuid:8301eeb8-1f5f-4d25-b576-11e14671d506"
replace droppeds5_404 = 1 if key == "uuid:8301eeb8-1f5f-4d25-b576-11e14671d506"

*dropout_period
replace dropout_period = 2 if key == "uuid:8301eeb8-1f5f-4d25-b576-11e14671d506"
replace dropout_period = 2 if key == "uuid:c93ab6c3-ebb6-44cc-9306-c32575754d5f"

*201_location 
la var loc_201 "201_location"

*board_day_202
replace board_day_202 = . if dropout == 1
notes replace house_201 in 1: "Questiontext : 201.g. Do you/ does your family rent or own the house?"
notes replace loc_201 in 1: "Question text : 201. f. Is your permant home located in urban or rural?"
notes replace board_day_202 in 1: "Question text : 202. Are you a boarding or day student?"
notes replace dist_min_203 in 1: "Question text: 203_How far is your home from the school? Answer in minutes"


*trans_204
replace trans_204 = . if dropout == 1

*dist_min_203
replace dist_min_203 = 1 if key == "uuid:17185117-4541-4264-bc97-7e797c03cae8"
replace dist_min_203 = 1 if key == "uuid:8f6b28dd-bdd9-4dc2-96a9-b56b9e38ff8b"
replace dist_min_203 = 5 if key == "uuid:0637fbb8-ae74-4843-b380-2a820c1ba68b"
replace dist_min_203 = 1 if key == "uuid:d7d335e3-fcc9-4bd3-b69c-2b6ace3e33a9"
replace dist_min_203 = 1 if key == "uuid:47e831a9-0394-4659-a175-635c3808cd7c"
replace dist_min_203 = 1 if key == "uuid:bb71c253-79fa-4677-badf-3d6a60e514c0"
replace dist_min_203 = 1 if key == "uuid:70bc616c-6109-42bf-821d-c6d07baf6a53"
replace dist_min_203 = 1 if key == "uuid:d219f26c-6f22-41c7-b9af-39ae75a49b9d"
replace dist_min_203 = 5 if key == "uuid:cc96a5eb-54c3-496e-a05c-8fc54264c158"
replace dist_min_203 = 1 if key == "uuid:32949b43-8f5e-4d92-b005-d1fc0eacc9c9"
replace dist_min_203 = 1 if key == "uuid:01d34313-5932-441a-bd82-7fba64948f56"
replace dist_min_203 = 1 if key == "uuid:9f492a63-fbc6-40d5-ad21-02bd41bb1c1c"
replace dist_min_203 = 1 if key == "uuid:275e31da-e080-4508-9976-6a0c8f7b4c7b"
replace dist_min_203 = 1 if key == "uuid:c6887b9e-70f3-40b7-baf2-ad0065283ad7"
replace dist_min_203 = 1 if key == "uuid:b8abf56f-ab65-43e4-abd8-1a4912c8167d"
replace dist_min_203 = 1 if key == "uuid:09a179de-f3bf-4499-9abf-74a245ef0aca"
replace dist_min_203 = 1 if key == "uuid:0ef315b1-71e5-4a04-8bc6-b2a9edcc890a"
replace dist_min_203 = 5 if key == "uuid:b4c5240c-7c78-441c-80fc-60dab5b9691f"
replace dist_min_203 = 5 if key == "uuid:fc81727f-c9bc-4f14-9a43-fccabaa1eb8f"
replace dist_min_203 = 5 if key == "uuid:0e7fe674-89ae-4031-8cfb-8333b9d1fed8"
replace dist_min_203 = 5 if key == "uuid:ff95a3f9-ef68-42b9-aac0-960350650819"
replace dist_min_203 = 1 if key == "uuid:59cf92a7-aa5f-484e-a4c0-07da8fc5ef3d"
replace dist_min_203 = 1 if key == "uuid:0a2b221f-0a8d-4634-a285-b7c26fd86ebb"
replace dist_min_203 = 1 if key == "uuid:69a94b92-1d3b-4aa2-8fa3-1d138c53a884"
replace dist_min_203 = 1 if key == "uuid:6324489c-78fb-4f61-9b28-0c2927197f01"

*dist_min_203
replace dist_min_203 = . if dropout == 1 
**because the question was not supposed to be asked dropout students

la var house_201 "201_Do you/ does your family rent or own the house?"
la var board_day_202 "202_Are you a boarding or day student?"
la var dist_min_203 "203_How far is your home from the school? Answer in minutes"
la var trans_204 "204_By which main means of transport do you travel to school?"


*3. Socioeconomic Background Characteristics 
**********************************************

*gender_301
replace gender_301 = 2 if key == "uuid:9f492a63-fbc6-40d5-ad21-02bd41bb1c1c"
replace gender_301 = 2 if key == "uuid:d40483bc-e948-44eb-a230-f301a107c5c1"
replace gender_301 = 1 if key == "uuid:275e31da-e080-4508-9976-6a0c8f7b4c7b"
replace gender_301 = 2 if key == "uuid:a64ef305-e52a-4e34-9d02-4ad3557ff737"
replace gender_301 = 1 if key == "uuid:7ba81a63-c116-4230-9e34-841645c0aab9"
replace gender_301 = 1 if key == "uuid:fac3cc3f-4d7a-4425-99b9-382ed78ed394"
replace gender_301 = 1 if key == "uuid:86545c7d-5c4d-4946-a97c-2a2e55f5cedd"
replace gender_301 = 1 if key == "uuid:aa81031c-5ed5-4c4a-90e8-013f6f18c25f"
replace gender_301 = 2 if key == "uuid:955c2f4f-2f7b-44ac-a6cf-743466254a5a"
replace gender_301 = 1 if key == "uuid:0b7d0a2c-a7ba-4cfb-b58d-ef6bd9f1f44a"
replace gender_301 = 1 if key == "uuid:7d88e769-42ca-4d6e-9c83-b200b17decf2"
replace gender_301 = 2 if key == "uuid:5c5a46f6-0f2d-4247-ae10-a2d6bec7d19f"
replace gender_301 = 2 if key == "uuid:538c138c-292d-43e2-a31b-c5b94f1ec3e8"
replace gender_301 = 2 if key == "uuid:de0e6aab-dc80-41c3-9d79-6a35c687e7ba"
replace gender_301 = 2 if key == "uuid:02a9008a-ed78-4e14-9a05-1be637ea7c90"
replace gender_301 = 1 if key == "uuid:f4e30bbe-80f7-489c-924f-ab5d3c637081"
replace gender_301 = 1 if key == "uuid:5663cfaa-fe58-4e0c-be4d-3ff38dcc6394"
replace gender_301 = 1 if key == "uuid:e9b51735-40fb-44e0-a105-54b4eb1dd44f"
replace gender_301 = 1 if key == "uuid:271e7582-6dd6-4c2c-b00c-a5a6db9b689a"
replace gender_301 = 1 if key == "uuid:941a36bb-3c77-4572-9eb5-fdeb4ddf33eb"
replace gender_301 = 2 if key == "uuid:0e9dfd25-e329-47bb-a37b-4436587c5dcf"
replace gender_301 = 1 if key == "uuid:3e0221ec-1ef7-4bea-9dec-b4a48469b7d5"
replace gender_301 = 1 if key == "uuid:9ec4193f-2c0b-45d8-960b-878d86fda49d"
replace gender_301 = 1 if key == "uuid:58c2cff7-acc6-4500-aac5-361f45c41e28"
replace gender_301 = 2 if key == "uuid:22393540-90c5-46d3-b4dc-dd86cd06ba0a"
replace gender_301 = 1 if key == "uuid:820c4f12-9def-4b0f-929c-4db073f67ab6"
replace gender_301 = 1 if key == "uuid:1631fe12-c859-4287-9f2f-b28f53133c23"
replace gender_301 = 2 if key == "uuid:ed75a03d-9f5a-4fb8-9257-c44e104a08db"
replace gender_301 = 2 if key == "uuid:54078558-8c0d-4d75-b955-752a86048c99"
replace gender_301 = 2 if key == "uuid:e39e975e-31a4-442d-8b67-e5e0e7f9e537"
replace gender_301 = 1 if key == "uuid:1ad5800a-41e4-4eb3-bfb0-1e56144927eb"
replace gender_301 = 1 if key == "uuid:696aa855-ce22-4c31-a210-44e9c17a19b2"
replace gender_301 = 1 if key == "uuid:fc1183ed-0d26-4a6d-a2db-aa461852ffad"
replace gender_301 = 2 if key == "uuid:11c9c9b5-bb7f-4854-b46a-7c037fc1bcec"
replace gender_301 = 1 if key == "uuid:63db2837-7f14-4a2e-9a55-4489443dc8f0"
replace gender_301 = 2 if key == "uuid:cd170818-77cb-4dc9-a464-4dcd766586c7"
replace gender_301 = 1 if key == "uuid:cfbbed39-bfd4-4610-8359-deb0b1c6cc4e"
replace gender_301 = 1 if key == "uuid:046a13b6-5c21-41c4-96f1-5121f7aaef96"
replace gender_301 = 1 if key == "uuid:d312d436-e5db-493c-90a3-fd37f5e79c4b"
replace gender_301 = 2 if key == "uuid:8b6f03b7-d6d8-4c8c-affa-c45ded71236a"
replace gender_301 = 2 if key == "uuid:69a8dca6-b2b1-4115-bcf4-83bbe7db35d2"
replace gender_301 = 1 if key == "uuid:b5a3b94c-5908-4c10-b181-0304bd1e93e3"
replace gender_301 = 2 if key == "uuid:e843666e-b8fd-4ba2-bf3b-0bbd74b46cdf"
replace gender_301 = 2 if key == "uuid:c2fd0a21-a1e2-4445-957f-44e680607e4b"
replace gender_301 = 1 if key == "uuid:5c93d636-cffa-4006-a506-591033ffc0ae"
replace gender_301 = 2 if key == "uuid:91a5159f-875d-4feb-aeb8-506df06ddeb3"
replace gender_301 = 2 if key == "uuid:301af19e-e26c-4bb4-9f21-6c7299a4596a"
replace gender_301 = 1 if key == "uuid:74c91519-f426-4c63-9f18-ba6f41e60065"
replace gender_301 = 1 if key == "uuid:864b6316-1a3a-4480-a4f5-ab0b6840cd25"
replace gender_301 = 1 if key == "uuid:c5bb7874-662f-47be-9875-4f9371e76f1b"
replace gender_301 = 2 if key == "uuid:6d6dd70d-c696-4ac0-b768-425f6a26667a"
replace gender_301 = 1 if key == "uuid:7f965c2b-21c2-4f07-aea5-e25ae4f513aa"
replace gender_301 = 1 if key == "uuid:56b0a23b-6ef7-416b-8bda-4f2099439553"
replace gender_301 = 1 if key == "uuid:a9010438-310b-4fca-9080-c89a1c59207d"
replace gender_301 = 1 if key == "uuid:893b9b7d-6c53-4800-a2db-47f4d45d04b5"
replace gender_301 = 1 if key == "uuid:ad2c5039-7cfb-45f0-a48f-dbbe731ea812"
replace gender_301 = 2 if key == "uuid:3c4623f0-3291-4e81-8b47-ab5224f84323"
replace gender_301 = 2 if key == "uuid:569ac1a6-4992-4260-8766-4f65c0d82842"
replace gender_301 = 2 if key == "uuid:21fef41c-a02e-4fcb-9e0d-ebef74bac572"
replace gender_301 = 1 if key == "uuid:6cd8f8b2-7746-4551-9912-fde194746116"
replace gender_301 = 1 if key == "uuid:f8f9ad2f-8a37-42ac-ad5e-2a29ba313c12"
replace gender_301 = 1 if key == "uuid:cbcb22d1-b0a4-4bfd-b600-bc84f6ce30ba"
replace gender_301 = 2 if key == "uuid:0a46baa6-9c37-41d6-8424-7a570e828854"
replace gender_301 = 1 if key == "uuid:f5b14b71-1555-4e66-9b1f-87f5e7a4b6a1"
replace gender_301 = 1 if key == "uuid:b1155ea2-5eca-4c96-a8f2-a712560fe21c"
replace gender_301 = 2 if key == "uuid:ac6cd850-c303-489d-a1f2-4582c7589252"
replace gender_301 = 2 if key == "uuid:d237c7be-72d6-48bc-b6be-e9f3e5659a92"
replace gender_301 = 2 if key == "uuid:c49ec956-608d-41f6-953f-de4c43e854f6"
replace gender_301 = 2 if key == "uuid:4e9d49fb-88ec-4dc4-b402-78f81aafe1c8"
replace gender_301 = 2 if key == "uuid:92855bec-6a89-40fe-be59-d1405527a105"
replace gender_301 = 1 if key == "uuid:669af5bc-7417-4d79-85f5-20bc5ff8b300"
replace gender_301 = 2 if key == "uuid:59e13a56-4e87-4946-a6ca-5b93d033772b"
replace gender_301 = 1 if key == "uuid:4480d385-4b09-4983-a1f1-ba4c6592eba5"
replace gender_301 = 1 if key == "uuid:8fb1549d-1607-4f31-a00a-5158a50e1fac"
replace gender_301 = 2 if key == "uuid:31a1a9bf-b21b-44ca-9a85-78d30c58b1b4"
replace gender_301 = 1 if key == "uuid:361239ed-fc58-49f4-9da9-118f347cc291"
replace gender_301 = 1 if key == "uuid:0e86eaaa-98d0-425e-9230-0fea517bc77c"
replace gender_301 = 2 if key == "uuid:709b00af-7aae-4cae-aae8-9da27b6349df"
replace gender_301 = 1 if key == "uuid:6183835b-73c4-4329-8d69-054f2ea63e3b"
replace gender_301 = 2 if key == "uuid:28cba8af-295f-4bd4-985f-73bd46e1f812"
replace gender_301 = 2 if key == "uuid:addb27c2-5f2c-4850-be49-2e0a803dcafb"
replace gender_301 = 1 if key == "uuid:c1a849e3-6b9d-44b6-a24e-739f26322d3e"
replace gender_301 = 2 if key == "uuid:ed8156f9-9a6d-42a0-89f6-baf6c663637c"
replace gender_301 = 2 if key == "uuid:ae693ec0-50d2-4ae5-8372-d67306f7b738"
replace gender_301 = 2 if key == "uuid:1a093a6c-00ec-4334-9f83-5c6e8fbcaed4"
replace gender_301 = 1 if key == "uuid:e23b1f45-626e-470d-bcfe-17841ad945be"
replace gender_301 = 1 if key == "uuid:489d3dad-ba38-42dd-892b-0bd6fb9351ed"
replace gender_301 = 1 if key == "uuid:1c413aa7-facf-46df-a505-0234c72e83c5"
replace gender_301 = 1 if key == "uuid:493f580c-5c70-45fe-83f7-0fe3d1b7a049"
replace gender_301 = 2 if key == "uuid:868933ba-6727-43f6-9b65-187f667bcb2c"
replace gender_301 = 2 if key == "uuid:81ed0769-f987-4032-a1b6-fc9b815175a3"
replace gender_301 = 2 if key == "uuid:db57e11d-f9d0-48e4-b613-026f0c2016c4"
replace gender_301 = 2 if key == "uuid:3f3b8430-2673-4df7-8e6b-602e140b2c1f"
replace gender_301 = 2 if key == "uuid:a6d568c4-a79d-4164-89d2-432f86110135"
replace gender_301 = 1 if key == "uuid:67199782-f33a-4c31-96f1-b1d91d73dee4"
replace gender_301 = 2 if key == "uuid:0ab535da-dccc-4e8a-97bb-36e49a13f47a"
replace gender_301 = 2 if key == "uuid:5ebd943d-d985-4b9d-af07-440a71db5a2c"
replace gender_301 = 2 if key == "uuid:eddff878-c283-4974-8cf7-f17c72d5bab4"
replace gender_301 = 2 if key == "uuid:6433e6a3-086f-48cd-acb5-9fe677810125"
replace gender_301 = 1 if key == "uuid:9c730558-9d7d-4de2-8954-bba34c00cb10"
replace gender_301 = 1 if key == "uuid:07e1bc99-f1b1-4f92-931a-f1bd16c4ae9a"
replace gender_301 = 2 if key == "uuid:b1857765-3728-479f-9f7b-00c8a18efde7"
replace gender_301 = 1 if key == "uuid:19aff931-eea0-44ec-ac31-4b9141b06e93"
replace gender_301 = 2 if key == "uuid:3436eb77-d6cf-49ba-8e2f-c7dfe1cf9c72"
replace gender_301 = 1 if key == "uuid:69c6dfbd-5bb3-40f3-90a0-06b27364b382"
replace gender_301 = 2 if key == "uuid:6a82b623-510f-4f57-a13b-f2e3a2d504dd"
replace gender_301 = 1 if key == "uuid:9dc73b16-214c-4c7a-82be-f02d8e09bdd7"
replace gender_301 = 2 if key == "uuid:baf5dd6c-f9f9-4e28-a186-85d891fb2da1"
replace gender_301 = 2 if key == "uuid:62300a72-5c41-4f31-b280-631afb1798fe"
replace gender_301 = 2 if key == "uuid:c8f6728b-d671-43f4-ad73-afe76675a986"
replace gender_301 = 2 if key == "uuid:3ee967a2-8581-4fdc-a587-84864ef1964e"
replace gender_301 = 2 if key == "uuid:b5699111-38da-4372-abef-dd911715d33a"
replace gender_301 = 2 if key == "uuid:392d3c5d-390c-4d8b-b8c8-61002387243e"
replace gender_301 = 2 if key == "uuid:94ff6e95-5001-4e03-983d-99d02c254d20"
replace gender_301 = 1 if key == "uuid:1cc6e050-4c4d-4c5c-acb2-4941dd63ebd0"
replace gender_301 = 1 if key == "uuid:ce2c0b1e-2bbb-495c-baa4-e06a65d4789a"
replace gender_301 = 1 if key == "uuid:4f6d3131-abf7-43f4-ba53-55531492f463"
replace gender_301 = 1 if key == "uuid:f2b8913a-3471-4497-bb88-34277d6c6257"
replace gender_301 = 2 if key == "uuid:29bdfeae-3537-40fa-919c-cf0d9f465058"
replace gender_301 = 2 if key == "uuid:f1c429cc-30de-49ed-80c3-14efba08c3cd"
replace gender_301 = 1 if key == "uuid:c6c6d478-5553-4248-a360-c40fe08bda54"
replace gender_301 = 1 if key == "uuid:d5347c04-a252-46c2-8f3c-d7b1a30d1a2f"
replace gender_301 = 1 if key == "uuid:e719df92-fe36-41bc-9193-603973b7dabe"
replace gender_301 = 1 if key == "uuid:10310367-1d30-49f4-8514-c7497fd22641"

*assets_306 
notes drop assets_306_Radio in 1 // droppped this as a duplicate note
notes drop assets_306_Television in 1 // droppped this as a duplicate note
notes drop assets_306_Telephone in 1 // droppped this as a duplicate note
notes drop assets_306_Refrigerator in 1 // droppped this as a duplicate note
notes drop assets_306_Bicycle in 1 // droppped this as a duplicate note
notes drop assets_306_Motorcycle in 1 // droppped this as a duplicate note
notes drop assets_306_PrivateCar in 1 // droppped this as a duplicate note
notes drop assets_306_Other in 1 // droppped this as a duplicate note
rename assets_306_Other assets_306_noneofabove // droppped this as a duplicate note
drop assets_306

**dropped corrected other variables
drop moth_occup_309_other fath_occup_309_other educ_sibling_310_other educ_fath_310_other cook_307_other water_305_other

*bus_info_212relationship_312
replace bus_info_212relationship_312 = 11 if bus_info_212relationship_312 == 12
replace bus_info_212relationship_312 = 12 if bus_info_212relationship_312 == 13

lab def bus_info_212relationship_312 1 "Mother" ///
2 "Father" ///
3 "Step-mother (your father’s second wife)" ///
4 "Step-father (your mother’s second husband)" ///
5 "Brother" ///
6 "Sister" ///
7 "Aunt (mother or father’s sister)" ///
8 "Uncle (mother of father’s brother)" ///
9 "Grandmother" ///
10 "Grandfather" ///
11 "Niece/nephew (daughter/son of your brother or sister)" ///
12 "Male or female cousin" ///
-99	"Don't know", modify
la val bus_info_212relationship_312 bus_info_212relationship_312


drop bus_info_212relationship_312_oth
*Section : 4. Income, Business, and Employment 
**********************************************

*type_busi_402

rename (type_busi_402_a_ type_busi_402_b_ type_busi_402_c_ type_busi_402_d_)(type_busi_402_own_bus type_busi_402_sbc_bus type_busi_402_meandpeers_bus type_busi_402_family_bus)

la de yesno 1 "Yes" 0 "No"
foreach var in type_busi_402_own_bus type_busi_402_sbc_bus type_busi_402_meandpeers_bus type_busi_402_family_bus{
lab val `var' yesno

}

*
replace bus_relation_405_1 = 1 if mosttime_busi_403 == 4 & owner_partner_404 != 0
*Because most of the family business is owned by parents

*
replace bus_relation_405_1 = 4 if mosttime_busi_403 == 2 & owner_partner_404 != 0
*Because most of the student business club businesses have Friends/Classmates as partners

*
destring bus_relation_405_count, replace

replace bus_relation_405_1 = 1 if bus_relation_405_count ==1
replace bus_relation_405_1 = 2 if bus_relation_405_count ==2
replace bus_relation_405_1 = 3 if bus_relation_405_count ==3
replace bus_relation_405_1 = 4 if bus_relation_405_count ==4
replace bus_relation_405_1 = 4 if key == "uuid:5e6804e1-efd3-4c5e-a94c-05e66ffa0687"
replace bus_relation_405_1 = 4 if key == "uuid:775638d1-399a-4225-be9f-c99b84c6b1ea"
drop bus_relation_405_count
notes drop bus_relation_405 in 2

**Note: Business having partners = 1,152 among which 736 with 0 partner. Thus, we cannot label the relationship with partners if there is 0 parners.
**We eventually have 1,152-736 = 416 labelled partners


rename (busi_activ_408_i busi_activ_408_ii busi_activ_408_iii busi_activ_408_iv busi_activ_408_v busi_activ_408__99 busi_activ_408_vii busi_activ_408_viii)(busi_activ_408_writprojideas busi_activ_408_creatproducts busi_activ_408_finrecords busi_activ_408_paidtax busi_activ_408_regwithgovt busi_activ_408_dontknow busi_activ_408_oth busi_activ_408_none)
foreach var in busi_activ_408_writprojideas busi_activ_408_creatproducts busi_activ_408_finrecords busi_activ_408_paidtax busi_activ_408_regwithgovt busi_activ_408_dontknow busi_activ_408_oth busi_activ_408_none{
lab val `var' yesno

}
drop busi_activ_408_other
order busi_activ_408_oth, after( busi_activ_408_none)

notes drop busi_activ_408_writprojideas in 2
notes drop busi_activ_408_creatproducts in 2
notes drop busi_activ_408_finrecords in 2
notes drop busi_activ_408_paidtax in 2
notes drop busi_activ_408_regwithgovt in 2
notes drop busi_activ_408_dontknow in 2
notes drop busi_activ_408_none in 2
notes drop busi_activ_408_oth in 2


rename (raise_money_413_1 raise_money_413_2 raise_money_413_3 raise_money_413_4 raise_money_413_5 raise_money_413_6 raise_money_413_7 raise_money_413_8)(raise_money_413_mothfath raise_money_413_brothsis raise_money_413_sbcprofit raise_money_413_diffamlymemb raise_money_413_friend raise_money_413_churchmtempl raise_money_413_some1else raise_money_413_raiself)
foreach var in raise_money_413_mothfath raise_money_413_brothsis raise_money_413_sbcprofit raise_money_413_diffamlymemb raise_money_413_friend raise_money_413_churchmtempl raise_money_413_some1else raise_money_413_raiself{
lab val `var' yesno

}

*type_busi_416_1
	#delimit ;
	label def type_busi_416_1
		12 "Selling services" ///
		13 "N/A"
		, add
		;
	#delimit cr

**
rename (oftenpaid_414_1 howmuch_415_1 type_busi_416_1)(oftenpaid_414 howmuch_415 type_busi_416)
replace howmuch_415 = 0 if key == "uuid:284a99bb-a459-4ff5-b336-1e95c5494b12"
replace howmuch_415 = 0 if key == "uuid:a7d47470-c467-46c0-a0f4-e536fa360ecc"
replace howmuch_415 = 0 if key == "uuid:003152bd-6b86-42d5-8460-e6d82500402b"
replace howmuch_415 = 0 if key == "uuid:e7aacc57-6399-463a-b9bd-da41b9679ef6"
replace howmuch_415 = 0 if key == "uuid:66c7312d-3706-4fed-bb83-5304765eed5d"
replace howmuch_415 = -99 if key == "uuid:00f03b21-1eb1-4f41-9c8b-056be61a9673"
replace howmuch_415 = 0 if key == "uuid:88e55d00-4db0-4aff-b7ed-e821849a77a2"


la var paid_holiday_417 "417. When you were on holiday, were you PAID to work at someone else’s business?"
*order paid_holiday_417, after( raise_money_413_raiself )
drop paid_holiday_count
drop paid_else_count
**adding notes 
notes replace paid_holiday_417 in 1: "417. When you were on holiday, were you PAID to work at someone else’s business? Do not include student business club activity or your own business activity."
notes replace withoutpay_428 in 1: "428. Are you working without pay for a business that generates income for your family or outside of your family?"


la var withoutpay_428 "428. Are you working without pay for a business that generates income for your family or outside of your family?"

foreach var in whenhome_429 whenhome_429_1 whenhome_429_2 whenhome_429_3 whenhome_429_4 whenhome_429_5 whenhome_429_6 whenhome_429_7 whenhome_429_8 whenhome_429_9{
lab var `var' "429. When at home, which of the following activities do you do on a regular basi"
}

foreach var in whenhome_429_1 whenhome_429_2 whenhome_429_3 whenhome_429_4 whenhome_429_5 whenhome_429_6 whenhome_429_7 whenhome_429_8 whenhome_429_9{
destring `var', replace
lab val `var' yesno
}

rename (whenhome_429_1 whenhome_429_2 whenhome_429_3 whenhome_429_4 whenhome_429_5 whenhome_429_6 whenhome_429_7 whenhome_429_8 whenhome_429_9)(whenhome_429_cooking whenhome_429_cleaning whenhome_429_studying whenhome_429_washcloth whenhome_429_caresibling whenhome_429_getwater whenhome_429_shopping whenhome_429_restplaying whenhome_429_allabove)

notes replace whenhome_429 in 1: "429. When at home, which of the following activities do you do on a regular basis (at least three times per week)?"
notes replace whenhome_429_cooking in 1: 429. When at home, which of the following activities do you do on a regular basi
notes replace whenhome_429_cleaning in 1: 429. When at home, which of the following activities do you do on a regular basi
notes replace whenhome_429_studying in 1: 429. When at home, which of the following activities do you do on a regular basi
notes replace whenhome_429_washcloth in 1: 429. When at home, which of the following activities do you do on a regular basi
notes replace whenhome_429_caresibling in 1: 429. When at home, which of the following activities do you do on a regular basi
notes replace whenhome_429_getwater in 1: 429. When at home, which of the following activities do you do on a regular basi
notes replace whenhome_429_shopping in 1: 429. When at home, which of the following activities do you do on a regular basi
notes replace whenhome_429_restplaying in 1: 429. When at home, which of the following activities do you do on a regular basi
notes replace whenhome_429_allabove in 1: 429. When at home, which of the following activities do you do on a regular basi


*Section 5. Academic Background and Performance
*********************************************
la var class_400e "400_Current class/level" // labelled to keep the same identity as the baseline var
la var opt_400e "400_Current option" // labelled to keep the same identity as the baseline var
la var stream_400e "400_Current stream" // labelled to keep the same identity as the baseline var

notes replace entr_teach_401 in 1: "401. What is the name of the entrepreneurship teacher?"
notes replace stream_400e in 1: "400.c. Current stream"
notes replace opt_400e in 1: "400.b. Current option"
notes replace class_400e in 1: "400.a. Current class/level"


*
la var aggr_404 "404. How did you score on your last promotional exam?"

*entr_teach_401
la var entr_teach_401 "401_What is the name of the entrepreneurship teacher?" // we rename/label the variable to make it ideintical to the baseline var

rename bus_relation_405_1 bus_relation_405

*
rename (reptimes4_403 reptimes5_403 reptimes6_403)(reptimes4_503e reptimes5_503e reptimes6_503e)
rename (droppeds4_404 droppeds5_404 droppeds6_404)(droppeds4_504e droppeds5_504e droppeds6_504e)
replace reptimes4_503e = -55 if reptimes4_503e == -77
replace reptimes5_503e = -55 if reptimes5_503e == -77
replace reptimes6_503e = -55 if reptimes6_503e == -77

replace droppeds4_504e = -55 if droppeds4_504e == -77
replace droppeds5_504e = -55 if droppeds5_504e == -77
replace droppeds6_504e = -55 if droppeds6_504e == -77

*la var reptimes5_503 "404_What was your aggregate mark on your Senior 3 National Exams"
rename proexam_405 proexam_505e

*4. Income, Business, and Employment 
************************************
rename earn_500e earn_receive_401e
la var earn_receive_401e "500. In the past month, did you earn or receive money by working or from running a business?"
rename amt_503 howmuch_401ae 
la var howmuch_401ae "503. How much have you earned in the last 2 months? Include all your sources of employment and business income? Write -99 if don’t know"
notes drop type_busi_402 in 2
notes drop howmuch_415 in 2

*Section 6. S4-S6 Classroom experience 

replace dividclass_600 = 6 if dividclass_600 == 7
replace present_group_603 = 6 if present_group_603 == 7
replace cond_res_607 = 6 if cond_res_607 == 7
replace fincalcul_608 = 6 if fincalcul_608 == 7
replace skillslab_610 = 6 if skillslab_610 == 7
replace takenote_610 = 6 if takenote_610 == 7 | takenote_610 == 8
replace careerplan_611 = 6 if careerplan_611 == 7

**labelled these below variables to keep consistency with baseline var
label variable stoodinclass_602 "602. During entrepreneurship class, have you stood in front of the class to pres"
label variable present_group_603 "603. During entrepreneurship class, how often have you or a member of your small"
label variable outclass_604 "604. During entrepreneurship class, how often has the teacher lead the class in "
label variable roleplay_605 "605. Role Play: Students in the class are divided into small groups, where each "
label variable clas_disc_606 "606. Classroom Discussions where students share their opinions or discuss what t"
label variable cond_res_607 "607. Conducted Research such as interviews, surveys, and internet searching"
label variable fincalcul_608 "608. Done Financial Calculations."
label variable work_comp_609 "609. Worked on the computer."
label variable skillslab_610 "610. Review a case study, or a story of a real-life situation where the students"
label variable takenote_610 "612. Career Planning"
rename takenote_610 takenote_612

*def_skillab_615
label variable def_skillab_615 "615. Give a definition to Skills Lab"
label variable def_skillab_616 "616. Give a definition to Skills Lab:multiple choice"
notes replace def_skillab_615 in 1: "615. Give a definition to Skills Lab"
notes replace def_skillab_616 in 1: "616. Give a definition to Skills Lab:multiple choice"


*Section 7. Student Business Club Activity
******************************************

*whosupp_701
rename (whosupp_701_1 whosupp_701_2 whosupp_701_3 whosupp_701_4 whosupp_701_5 whosupp_701_6 whosupp_701_7)(whosupp_701_entrprteacher whosupp_701_otherteacher whosupp_701_headteacher whosupp_701_parents whosupp_701_anothentrepreneur whosupp_701_schoolofficial whosupp_701_none)
foreach var in whosupp_701_entrprteacher whosupp_701_otherteacher whosupp_701_headteacher whosupp_701_parents whosupp_701_anothentrepreneur whosupp_701_schoolofficial whosupp_701_none{
la val `var' yesno
}
notes drop whosupp_701_entrprteacher in 2
notes drop whosupp_701_otherteacher in 2
notes drop whosupp_701_headteacher in 2
notes drop whosupp_701_parents in 1
notes drop whosupp_701_anothentrepreneur in 2
notes drop whosupp_701_schoolofficial in 2
notes drop whosupp_701_none in 2

*typesupp_702
rename (typesupp_702_1 typesupp_702_2 typesupp_702_3 typesupp_702_4 typesupp_702_5 typesupp_702_7 typesupp_702_6)(typesupp_702_sbcleadership typesupp_702_att1meeting typesupp_702_attmeetfreqntly typesupp_702_sbcchallenges typesupp_702_mgtscbfunds typesupp_702_other typesupp_702_none)
foreach var in typesupp_702_sbcleadership typesupp_702_att1meeting typesupp_702_attmeetfreqntly typesupp_702_sbcchallenges typesupp_702_mgtscbfunds typesupp_702_other typesupp_702_none{
la val `var' yesno
}

*make_product_706
rename (make_product_706_1 make_product_706_2 make_product_706_3 make_product_706_4 make_product_706_5 make_product_706_6 make_product_706_7 make_product_706_8 make_product_706_9 make_product_706_10 make_product_706_11 make_product_706_12 make_product_706_13 make_product_706_14)(make_product_706_Candles make_product_706_LiquidSoap make_product_706_Paperbags make_product_706_Paperbeads make_product_706_Baskets make_product_706_pastryprodcts make_product_706_decorations make_product_706_handcrafts make_product_706_jewellery make_product_706_shoepolishcream make_product_706_juice make_product_706_bodycream make_product_706_paints make_product_706_pottery)
foreach var in make_product_706_Candles make_product_706_LiquidSoap make_product_706_Paperbags make_product_706_Paperbeads make_product_706_Baskets make_product_706_pastryprodcts make_product_706_decorations make_product_706_handcrafts make_product_706_jewellery make_product_706_shoepolishcream make_product_706_juice make_product_706_bodycream make_product_706_paints make_product_706_pottery{
la val `var' yesno
}

*fromwgom_707
rename (fromwgom_707_1 fromwgom_707_2 fromwgom_707_3 fromwgom_707_4)(fromwgom_707_entrpteacher fromwgom_707_fellowstud fromwgom_707_parents fromwgom_707_anothentrpneur)
foreach var in fromwgom_707_entrpteacher fromwgom_707_fellowstud fromwgom_707_parents fromwgom_707_anothentrpneur{
lab val `var' yesno 
}

*savedmon_804
drop savedmon_804__66
rename (savedmon_804_1 savedmon_804_2 savedmon_804_3 savedmon_804_4 savedmon_804_5 savedmon_804_6 savedmon_804_7 savedmon_804_8 savedmon_804_9)(savedmon_804e_nosavings savedmon_804e_hiddenboxdrawer savedmon_804e_anothpersholds savedmon_804e_groupaccount savedmon_804e_individaccount savedmon_804e_SACCOaccount savedmon_804e_phoneaccount savedmon_804e_ROSCA savedmon_804e_VSLA)
label values savedmon_804e_ROSCA rosca
notes drop savedmon_804e_VSLA in 2
foreach var in savedmon_804e_nosavings savedmon_804e_hiddenboxdrawer savedmon_804e_anothpersholds savedmon_804e_groupaccount savedmon_804e_individaccount savedmon_804e_SACCOaccount savedmon_804e_phoneaccount savedmon_804e_ROSCA savedmon_804e_VSLA{
lab val `var' yesno
}

*busplan_901
rename busplan_901 proftamt_1002
la var proftamt_1002 "1002. Suppose you started selling paper bags at 800 FRW. It costs 600 FRW for the materials to make the bags. You sell 5 paper bags per day. How much profit would your business earn in 1 month (30 days)? Type -99 if don't know"

notes replace proftamt_1002 in 1: "1002. Suppose you started selling paper bags at 800 FRW. It costs 600 FRW for the materials to make the bags. You sell 5 paper bags per day. How much profit would your business earn in 1 month (30 days)?"


*incrproft_903 to incrproft_1003 // Renamed and labelled this variable to make it consistent with the baseline data
rename incrproft_903 incrproft_1003
la var incrproft_1003 "1003. In the above example from question 900, how would you be able to increase this monthly profit? Choose all that apply."

foreach var in incrproft_1003_SellMorePaper incrproft_1003_IncreasPrice incrproft_1003_EmploySone incrproft_1003_UseCheaperMat incrproft_903__66 incrproft_903__55{
lab var `var' "1003. In the above example from question 900, how would you be able to increase this monthly profit? Choose all that apply."
lab val `var' yesno 
notes `var': "1003. In the above example from question 900, how would you be able to increase this monthly profit? Choose all that apply."
}
drop incrproft_903__66
rename incrproft_903__55 incrproft_1003__noanswer

notes drop incrproft_1003_SellMorePaper in 1
notes drop incrproft_1003_IncreasPrice in 1
notes drop incrproft_1003_EmploySone in 1
notes drop incrproft_1003_UseCheaperMat in 1
notes drop incrproft_1003__noanswer in 1
notes replace incrproft_1003 in 1: "1003. In the above example from question 900, how would you be able to increase this monthly profit?"



*
la var notbusgrth_1004 "1004. Which of the following is NOT considered an indicator of business growth? Choose all that apply."


foreach var in notbusgrth_1004_1 notbusgrth_1004_2 notbusgrth_1004_3 notbusgrth_1004_4 notbusgrth_1004_5 notbusgrth_1004__66 notbusgrth_1004__99{
lab var `var' "1004. Which of the following is NOT considered an indicator of business growth? Choose all that apply."
lab val `var' yesno
notes `var': "1004. Which of the following is NOT considered an indicator of business growth? Choose all that apply."
}
rename (notbusgrth_1004_1 notbusgrth_1004_2 notbusgrth_1004_3 notbusgrth_1004_4 notbusgrth_1004_5 notbusgrth_1004__66 notbusgrth_1004__99)(notbusgrth_1004_increasales notbusgrth_1004_increasprofit notbusgrth_1004_increasliqasst notbusgrth_1004_increasliablt notbusgrth_1004_increasmrktshare notbusgrth_1004_other notbusgrth_1004__donoknow)
notes replace notbusgrth_1004 in 1: "1004. Which of the following is NOT considered an indicator of business growth?"
notes drop notbusgrth_1004_increasales in 1
notes drop notbusgrth_1004_increasprofit in 1
notes drop notbusgrth_1004_increasliqasst in 1
notes drop notbusgrth_1004_increasliablt in 1
notes drop notbusgrth_1004_increasmrktshare in 1
notes drop notbusgrth_1004__donoknow in 1

drop notbusgrth_1004_other

*
la var knownoproft_1005 "1005. How do you know a business is not profitable?"
la def knownoproft_1005 1 "The cost of making a product is more than the selling price" ///
2 "The cost of making a product is less than the selling price" ///
3 "Selling less than 50% of your  products" ///
4 "Selling more than 50% of your  products" ///
-66	"Other" ///
-99	"Don't know" 

la val knownoproft_1005 knownoproft_1005
notes replace knownoproft_1005 in 1: "1005. How do you know a business is not profitable?"
*
la var occup_1101 "1101. After school, what occupation would you like to have in your life?"
la def occup_1101 1 "Yes" 0 "No"
la val occup_1101 occup_1101
notes replace occup_1101 in 1: "1101. After school, what occupation would you like to have in your life?"

*
la var busnsftr_1102 "1102_Do you plan to start a business in the future?)"
la def busnsftr_1102 1 "Yes" 0 "No"
la val busnsftr_1102 busnsftr_1102
notes replace busnsftr_1102 in 1: "1102_Do you plan to start a business in the future?)"

*Section 9. Aspirations
****************************************************
label variable schooling_1100 "1100. What is the highest level of schooling you plan to complete?"
notes replace schooling_1100 in 1: "1100. What is the highest level of schooling you plan to complete?"
la def schooling_1100 1 "Yes" 0 "No"
la val schooling_1100 schooling_1100

*Section 11. Community Participation and Leadership 
******************************************************

*comm_project_1101e
rename comm_project_1100 comm_project_1101e
la var comm_project_1101e "1101. Do you have a community project that YOU STARTED YOURSELF?"
la val comm_project_1101e yesno
notes replace comm_project_1101e in 1: "1101. Do you have a community project that YOU STARTED YOURSELF?"

*
rename large_project_1102 large_project_1102e
la var large_project_1102e "1102. If you have more than one project, answer the following questions about yo"
notes replace large_project_1102e in 1: "1102. If you have more than one project, answer the following questions about your largest project only. What is the project?"

*
rename indiv_role_1103 indiv_role_1103e
la var indiv_role_1103e "1103. In group discussions every group member contributes something unique to th"
notes replace indiv_role_1103e in 1: "1103. In group discussions every group member contributes something unique to the discussion through playing some individual roles."

*
rename concern_comm_1104 concern_comm_1106e
la var concern_comm_1106e "1106. Are you concerned about any problems in your community/school? (e. g. pove"
la val concern_comm_1106e yesno

rename solveproblm_1105 solveproblm_1107e
la var solveproblm_1107e "1107. Many students are concerned about the problems in their school or community. Have you done anything to solve or raise awareness about these problems? Tick all of the activities you did"

foreach var in solveproblm_1105_1 solveproblm_1105_2 solveproblm_1105_3 solveproblm_1105_4 solveproblm_1105_5 solveproblm_1105_6 solveproblm_1105_7{
lab var `var' "1107. Many students are concerned about the problems in their school or community. Have you done anything to solve or raise awareness about these problems? Tick all of the activities you did"
lab val `var' yesno
notes `var': "1107. Many students are concerned about the problems in their school or community. Have you done anything to solve or raise awareness about these problems? Tick all of the activities you did"
}
rename (solveproblm_1105_1 solveproblm_1105_2 solveproblm_1105_3 solveproblm_1105_4 solveproblm_1105_5 solveproblm_1105_6 solveproblm_1105_7)(solveproblm_1107e_havenot solveproblm_1107e_startcomprojct solveproblm_1107e_talkproblmfr solveproblm_1107e_startclub solveproblm_1107e_joindclub solveproblm_1107e_orgzawarness solveproblm_1107e_didsthelse)

notes drop visit_date_112 in 2
label values endtime Endtime
notes endtime: Endtime
notes drop solveproblm_1107e_didsthelse in 1
notes drop solveproblm_1107e_didsthelse in 2
notes drop solveproblm_1107e_orgzawarness in 1
notes drop solveproblm_1107e_joindclub in 1
notes drop solveproblm_1107e_startclub in 1
notes drop solveproblm_1107e_talkproblmfr in 1
notes drop solveproblm_1107e_startcomprojct in 1
notes drop solveproblm_1107e_havenot in 1
notes replace solveproblm_1107e in 1: "1107. Many students are concerned about the problems in their school or community. Have you done anything to solve or raise awareness about these problems? Tick all of the activities you did"
notes solveproblm_1107e_didsthelse: "1107. Many students are concerned about the problems in their school or community. Have you done anything to solve or raise awareness about these problems? Tick all of the activities you did"
notes replace concern_comm_1106e in 1: "1106. Are you concerned about any problems in your community/school? (e. g. poverty, drug / alcohol abuse, poor access to clean water, etc. )"
la def concern_comm_1106 1 "Yes" 0 "No"
 
notes drop enum_comments in 1

notes replace aggr_404 in 1: "404. How did you score on your last promotional exam?"
notes replace stoodinclass_602 in 1: "602. During entrepreneurship class, have you stood in front of the class to present or talk about any work you or your small group did?"
notes replace present_group_603 in 1: "603. During entrepreneurship class, how often have you or a member of your small group presented the group’s work to your class?"
notes replace outclass_604 in 1: "604. During entrepreneurship class, how often has the teacher lead the class in an activity outside of the classroom (school survey, field trip, energizer outside, visit to school farm etc)?"
notes replace roleplay_605 in 1: "605. Role Play: Students in the class are divided into small groups, where each group must act a part by pretending to be a different person"
notes replace clas_disc_606 in 1: "606. Classroom Discussions where students share their opinions or discuss what they know."
notes replace cond_res_607 in 1: "607. Conducted Research such as interviews, surveys, and internet searching"
notes replace fincalcul_608 in 1: "608. Done Financial Calculations."
notes replace work_comp_609 in 1: "609. Worked on the computer."
notes replace skillslab_610 in 1: "610. Review a case study, or a story of a real-life situation where the students must discuss or solve a problem or resolve a conflict."
notes drop careerplan_611 in 1
notes replace careerplan_611 in 2: "611. Career Planning"
notes drop takenote_612 in 1
notes replace takenote_612 in 2: "612. Taken Notes"
la var careerplan_611 "611_Career Planning"
la var takenote_612 "612_Taken notes"
la def takenote_612 1 "Yes" 0 "No"
la val takenote_612 takenote_612

la def why_1205lab 1 "Yes" 0 "No"
la val reas_1205 why_1205lab

*save "C:\Users\POkull\Box Sync\IPA_RWA_Projects\IPA_RWA_Project_Educate\07_Questionnaires&Data\06 Endline_Quantitative\Data\Raw_data\student_endline_clean_prefinal", replace
save "C:\Users\ANasabimana\Box Sync\IPA_RWA_Project_Educate\07_Questionnaires&Data\06 Endline_Quantitative\Data\Raw_data\student_endline_clean_prefinal", replace


*Adding student names to the final endline students' dataset
clear all
*use "C:\Users\POkull\Box Sync\IPA_RWA_Projects\IPA_RWA_Project_Educate\07_Questionnaires&Data\06 Endline_Quantitative\Data\Raw_data\names_track.dta", clear // contains all the endline student names from the student tracking endline survey dataset
use "C:\Users\ANasabimana\Box Sync\IPA_RWA_Project_Educate\07_Questionnaires&Data\06 Endline_Quantitative\Data\Raw_data\names_track.dta", clear // contains all the endline student names from the student tracking endline survey dataset

*append using "C:\Users\POkull\Box Sync\IPA_RWA_Projects\IPA_RWA_Project_Educate\07_Questionnaires&Data\06 Endline_Quantitative\Data\Raw_data\names_end.dta" // contains all the endline student names from the endline survey dataset
append using "C:\Users\ANasabimana\Box Sync\IPA_RWA_Project_Educate\07_Questionnaires&Data\06 Endline_Quantitative\Data\Raw_data\names_end.dta" // contains all the endline student names from the endline survey dataset

rename (first_name_200 family_name_200)(first_name family_name)
sort key
*save "C:\Users\POkull\Box Sync\IPA_RWA_Projects\IPA_RWA_Project_Educate\07_Questionnaires&Data\06 Endline_Quantitative\Data\Raw_data\allnames_endline.dta", replace
save "C:\Users\ANasabimana\Box Sync\IPA_RWA_Project_Educate\07_Questionnaires&Data\06 Endline_Quantitative\Data\Raw_data\allnames_endline.dta", replace

*Now we merge all names (from both tracking and endline student surveys) to the clean dataset
clear all
*use "C:\Users\POkull\Box Sync\IPA_RWA_Projects\IPA_RWA_Project_Educate\07_Questionnaires&Data\06 Endline_Quantitative\Data\Raw_data\allnames_endline.dta"
use "C:\Users\ANasabimana\Box Sync\IPA_RWA_Project_Educate\07_Questionnaires&Data\06 Endline_Quantitative\Data\Raw_data\allnames_endline.dta"

sort key
*merge 1:1 key using "C:\Users\POkull\Box Sync\IPA_RWA_Projects\IPA_RWA_Project_Educate\07_Questionnaires&Data\06 Endline_Quantitative\Data\Raw_data\student_endline_clean_prefinal" // the dataset generated after final cleanings of var names/labels/inconcinstencies, etc
merge 1:1 key using "C:\Users\ANasabimana\Box Sync\IPA_RWA_Project_Educate\07_Questionnaires&Data\06 Endline_Quantitative\Data\Raw_data\student_endline_clean_prefinal" // the dataset generated after final cleanings of var names/labels/inconcinstencies, etc
order first_name family_name, after(family_name_200)
drop if _merge == 1
drop _merge
order key, after(formdef_version)
drop first_name_200 family_name_200
rename(first_name family_name) (first_name_200 family_name_200)
replace first_name_200 = first_name_b if  family_name_200 == ""
replace family_name_200 = family_name_b if  family_name_200 == ""

drop first_name_b family_name_b

//corrected var becuase there was no logic to ask this this question to a dropout student
*replace class_400e=. if dropout==1

//replaced GS Juru and GS Mukono whose names were inversely assigned
replace school_name= 45 if schoolid== 405102
replace school_name= 95 if schoolid== 504102

replace group_107 = 2 if schoolid == 405102
replace group_107 = 1 if schoolid == 504102

//adding the teacher linking id
merge 1:1 key using "C:\Users\ANasabimana\Box Sync\IPA_RWA_Project_Educate\07_Questionnaires&Data\06 Endline_Quantitative\Data\Raw_data\linkid_final.dta"
order entr_teach_401_check teacherid_link, after(entr_teach_401)
drop entr_teach_401_check
drop _merge


//
/*
> *****PART 1: DISCREPANCIES IN SCHOOL IDS***************;
. * 1. SCHOOLID DOES NOT MATCH REENTER_SCHOOLID;
. sort schoolid uniqueid;

. list schoolid reenter_schoolid school_name school school_code_106 uniqueid if schoolid!=reenter_schoolid;
*/

replace reenter_schoolid = 401115 if reenter_schoolid  == 40111513 & key == "uuid:67377640-e291-4f7b-a618-24cfa3dbc8e8"
replace reenter_schoolid = 402032 if reenter_schoolid  == 402052 & key == "uuid:f11f4352-2ee1-41ec-842f-8f1285f9981b"
replace reenter_schoolid = 402032 if reenter_schoolid  == 402052 & key == "uuid:1cb617c6-4a22-4e41-ae3b-b743a38dbef3"
replace reenter_schoolid = 403129 if reenter_schoolid  == 40312911 & key == "uuid:51199cb0-3622-480c-9925-50a0886c1958"
replace reenter_schoolid = 405120 if reenter_schoolid  == 4512 & key == "uuid:1b419509-20f4-43b0-a2c3-9ccc04061d4d"
replace reenter_schoolid = 405120 if reenter_schoolid  == 4512 & key == "uuid:e1f7dd0f-aed6-4e6a-ab08-405c84a0872b"
replace reenter_schoolid = 405120 if reenter_schoolid  == 4512 & key == "uuid:19f12901-2f49-4394-bf0b-8ba67c3362cd"
replace reenter_schoolid = 503014 if reenter_schoolid  == 50301421 & key == "uuid:11d02ad1-ec2f-4d92-9d34-7bcbd38e8427"
replace reenter_schoolid = 504108 if reenter_schoolid  == 52 & key == "uuid:d41463b1-d5dd-49a0-b31e-668110a77598"
replace reenter_schoolid = 506117 if reenter_schoolid  == 5061171 & key == "uuid:4c8db73e-34f7-453e-8d73-bf0212cb9b74"
replace reenter_schoolid = 9999258 if reenter_schoolid  == 507104 & key == "uuid:a872524d-c265-4a05-8a67-8ba139592ce0"

// GS Juru vs GS Mukono (405102 if school_name == 95)
*Note: the school code for GS Juru (if school_name == 45) was changed to 5041021 at endline but the uniqueid was kept intact
replace reenter_schoolid =5041021 if reenter_schoolid == 5041021 & key == "uuid:ad2c5039-7cfb-45f0-a48f-dbbe731ea812"
replace reenter_schoolid =5041021 if reenter_schoolid == 5041021 & key == "uuid:6122c3db-1065-4cff-b789-51911ef5c414"
replace reenter_schoolid =5041021 if reenter_schoolid == 5041021 & key == "uuid:6bd14fad-1c93-4aca-a19a-5ee4e396c54d"
replace reenter_schoolid =5041021 if reenter_schoolid == 5041021 & key == "uuid:c1fbecda-9c97-4c2b-9709-8616c00ce27e"
replace reenter_schoolid =5041021 if reenter_schoolid == 5041021 & key == "uuid:6d6dd70d-c696-4ac0-b768-425f6a26667a"
replace reenter_schoolid =5041021 if reenter_schoolid == 5041021 & key == "uuid:a9010438-310b-4fca-9080-c89a1c59207d"
replace reenter_schoolid =5041021 if reenter_schoolid == 5041021 & key == "uuid:c5bb7874-662f-47be-9875-4f9371e76f1b"
replace reenter_schoolid =5041021 if reenter_schoolid == 405102 & key == "uuid:893b9b7d-6c53-4800-a2db-47f4d45d04b5"
replace reenter_schoolid =5041021 if reenter_schoolid == 5041021 & key == "uuid:ba4c24ab-b7fd-438b-b9b3-392852965f17"
replace reenter_schoolid =5041021 if reenter_schoolid == 405102 & key == "uuid:33e26f84-9e21-4be5-8421-c03b10a13660"
replace reenter_schoolid =5041021 if reenter_schoolid == 5041021 & key == "uuid:5bce933b-4e17-4f33-9379-d712e99e9d84"
replace reenter_schoolid =5041021 if reenter_schoolid == 5041021 & key == "uuid:7f58db43-6d54-4f26-99be-90e18c2f3bb8"
replace reenter_schoolid =5041021 if reenter_schoolid == 5041021 & key == "uuid:936228d1-aa4c-4b2a-9c94-22a1aa534989"
replace reenter_schoolid =5041021 if reenter_schoolid == 5041021 & key == "uuid:372e1156-45b2-410d-8689-c254345b9542"
replace reenter_schoolid =5041021 if reenter_schoolid == 5041021 & key == "uuid:3f773468-2c12-4ab7-ad6f-5f20599177a6"
replace reenter_schoolid =5041021 if reenter_schoolid == 5041021 & key == "uuid:7f965c2b-21c2-4f07-aea5-e25ae4f513aa"
replace reenter_schoolid =5041021 if reenter_schoolid == 5041021 & key == "uuid:77893908-4241-480a-8eee-f1b55e4019c9"
replace reenter_schoolid =5041021 if reenter_schoolid == 5041021 & key == "uuid:56b0a23b-6ef7-416b-8bda-4f2099439553"


//  * 3. SCHOOL_CODE_106 DOES NOT MATCH FIRST DIGITS OF STUDENTID;
replace uniqueid = "3011172" if uniqueid == "3021172" & key == "uuid:15bb1baf-230d-4f89-8149-d2b5b725973e"
replace reenter_studentid_202 = 3011172 if reenter_studentid_202 == 3021172 & key == "uuid:15bb1baf-230d-4f89-8149-d2b5b725973e"

//Corrected GS Juru & GS Mukono
replace schoolid = 504102 if schoolid == 405102 & key == "uuid:ad2c5039-7cfb-45f0-a48f-dbbe731ea812"
replace schoolid = 504102 if schoolid == 405102 & key == "uuid:6122c3db-1065-4cff-b789-51911ef5c414"
replace schoolid = 504102 if schoolid == 405102 & key == "uuid:6bd14fad-1c93-4aca-a19a-5ee4e396c54d"
replace schoolid = 504102 if schoolid == 405102 & key == "uuid:c1fbecda-9c97-4c2b-9709-8616c00ce27e"
replace schoolid = 504102 if schoolid == 405102 & key == "uuid:6d6dd70d-c696-4ac0-b768-425f6a26667a"
replace schoolid = 504102 if schoolid == 405102 & key == "uuid:a9010438-310b-4fca-9080-c89a1c59207d"
replace schoolid = 504102 if schoolid == 405102 & key == "uuid:c5bb7874-662f-47be-9875-4f9371e76f1b"
replace schoolid = 504102 if schoolid == 405102 & key == "uuid:893b9b7d-6c53-4800-a2db-47f4d45d04b5"
replace schoolid = 504102 if schoolid == 405102 & key == "uuid:ba4c24ab-b7fd-438b-b9b3-392852965f17"
replace schoolid = 504102 if schoolid == 405102 & key == "uuid:33e26f84-9e21-4be5-8421-c03b10a13660"
replace schoolid = 504102 if schoolid == 405102 & key == "uuid:5bce933b-4e17-4f33-9379-d712e99e9d84"
replace schoolid = 504102 if schoolid == 405102 & key == "uuid:7f58db43-6d54-4f26-99be-90e18c2f3bb8"
replace schoolid = 504102 if schoolid == 405102 & key == "uuid:936228d1-aa4c-4b2a-9c94-22a1aa534989"
replace schoolid = 504102 if schoolid == 405102 & key == "uuid:372e1156-45b2-410d-8689-c254345b9542"
replace schoolid = 504102 if schoolid == 405102 & key == "uuid:3f773468-2c12-4ab7-ad6f-5f20599177a6"
replace schoolid = 504102 if schoolid == 405102 & key == "uuid:7f965c2b-21c2-4f07-aea5-e25ae4f513aa"
replace schoolid = 504102 if schoolid == 405102 & key == "uuid:77893908-4241-480a-8eee-f1b55e4019c9"
replace schoolid = 504102 if schoolid == 405102 & key == "uuid:56b0a23b-6ef7-416b-8bda-4f2099439553"
replace schoolid = 405102 if schoolid == 504102 & key == "uuid:1fa0d7de-0940-49b9-8178-041f0b2b1f6b"
replace schoolid = 405102 if schoolid == 504102 & key == "uuid:9c556a6c-8592-4c76-84cd-01d1b4d64b09"
replace schoolid = 405102 if schoolid == 504102 & key == "uuid:1bcbd16d-2bad-46cd-9d74-246e740dde27"
replace schoolid = 405102 if schoolid == 504102 & key == "uuid:988ac628-4e81-4699-9f6f-d4ff220978f9"
replace schoolid = 405102 if schoolid == 504102 & key == "uuid:0ac8317d-0413-4596-991d-ebe62250a010"
replace schoolid = 405102 if schoolid == 504102 & key == "uuid:3cac4efe-3bc2-4146-adf4-9e616f686204"
replace schoolid = 405102 if schoolid == 504102 & key == "uuid:e20e4519-fec1-44aa-89d0-92144ed7f897"
replace schoolid = 405102 if schoolid == 504102 & key == "uuid:8ecaa302-f323-4815-8975-717d1d62d263"
replace schoolid = 405102 if schoolid == 504102 & key == "uuid:327d9695-276e-4ff1-b64f-9c540d5746b0"
replace schoolid = 405102 if schoolid == 504102 & key == "uuid:38f03104-380d-458e-90d5-907832f40221"
replace schoolid = 405102 if schoolid == 504102 & key == "uuid:6a7b7c0b-461c-4a02-af87-524ea1da39b3"
replace schoolid = 405102 if schoolid == 504102 & key == "uuid:647fc377-0954-45d2-9fca-5000f496fac8"
replace schoolid = 405102 if schoolid == 504102 & key == "uuid:39c2d43d-edb7-4494-8c7b-139d0ca8437d"
replace schoolid = 405102 if schoolid == 504102 & key == "uuid:b1539df0-b4d9-4ced-bcb5-19ebeaf0df3e"
replace schoolid = 405102 if schoolid == 504102 & key == "uuid:2b0db8a6-08ed-476a-8e1b-c1fd612e129e"
replace schoolid = 405102 if schoolid == 504102 & key == "uuid:96ef9738-f532-40c9-97d1-5ad70ba827bf"

replace reenter_schoolid = 504102 if schoolid == 504102 & school_name == 45
replace reenter_schoolid = 405102 if schoolid == 405102 & school_name == 95

//Fixs uniqueid IDs at GS Juru to match the baseline data
replace uniqueid = "40510214" if uniqueid == "504102114" & key == "uuid:6d6dd70d-c696-4ac0-b768-425f6a26667a"
replace reenter_studentid_202 = 40510214 if reenter_studentid_202 == 504102114 & key == "uuid:6d6dd70d-c696-4ac0-b768-425f6a26667a"

replace uniqueid = "40510219" if uniqueid == "504102119" & key == "uuid:372e1156-45b2-410d-8689-c254345b9542"
replace reenter_studentid_202 = 40510219 if reenter_studentid_202 == 504102119 & key == "uuid:372e1156-45b2-410d-8689-c254345b9542"

replace uniqueid = "40510220" if uniqueid == "4501220" & key == "uuid:893b9b7d-6c53-4800-a2db-47f4d45d04b5"
replace reenter_studentid_202 = 40510220 if reenter_studentid_202 == 4501220 & key == "uuid:893b9b7d-6c53-4800-a2db-47f4d45d04b5"

replace uniqueid = "40510221" if uniqueid == "504102121" & key == "uuid:77893908-4241-480a-8eee-f1b55e4019c9"
replace reenter_studentid_202 = 40510221 if reenter_studentid_202 == 504102121 & key == "uuid:77893908-4241-480a-8eee-f1b55e4019c9"

replace uniqueid = "40510224" if uniqueid == "504102124" & key == "uuid:c1fbecda-9c97-4c2b-9709-8616c00ce27e"
replace reenter_studentid_202 = 40510224 if reenter_studentid_202 == 504102124 & key == "uuid:c1fbecda-9c97-4c2b-9709-8616c00ce27e"

replace uniqueid = "40510217" if uniqueid == "504102117" & key == "uuid:3f773468-2c12-4ab7-ad6f-5f20599177a6"
replace reenter_studentid_202 = 40510217 if reenter_studentid_202 == 504102117 & key == "uuid:3f773468-2c12-4ab7-ad6f-5f20599177a6"

replace uniqueid = "4051023" if uniqueid == "50410213" & key == "uuid:56b0a23b-6ef7-416b-8bda-4f2099439553"
replace reenter_studentid_202 = 4051023 if reenter_studentid_202 == 50410213 & key == "uuid:56b0a23b-6ef7-416b-8bda-4f2099439553"

replace uniqueid = "4051025" if uniqueid == "50410215" & key == "uuid:a9010438-310b-4fca-9080-c89a1c59207d"
replace reenter_studentid_202 = 4051025 if reenter_studentid_202 == 50410215 & key == "uuid:a9010438-310b-4fca-9080-c89a1c59207d"

replace uniqueid = "40510223" if uniqueid == "504102123" & key == "uuid:936228d1-aa4c-4b2a-9c94-22a1aa534989"
replace reenter_studentid_202 = 40510223 if reenter_studentid_202 == 504102123 & key == "uuid:936228d1-aa4c-4b2a-9c94-22a1aa534989"

replace uniqueid = "40510213" if uniqueid == "504102113" & key == "uuid:c5bb7874-662f-47be-9875-4f9371e76f1b"
replace reenter_studentid_202 = 40510213 if reenter_studentid_202 == 504102113 & key == "uuid:c5bb7874-662f-47be-9875-4f9371e76f1b"

replace uniqueid = "4051022" if uniqueid == "50410212" & key == "uuid:ad2c5039-7cfb-45f0-a48f-dbbe731ea812"
replace reenter_studentid_202 = 4051022 if reenter_studentid_202 == 50410212 & key == "uuid:ad2c5039-7cfb-45f0-a48f-dbbe731ea812"

replace uniqueid = "40510222" if uniqueid == "504102122" & key == "uuid:6bd14fad-1c93-4aca-a19a-5ee4e396c54d"
replace reenter_studentid_202 = 40510222 if reenter_studentid_202 == 504102122 & key == "uuid:6bd14fad-1c93-4aca-a19a-5ee4e396c54d"

replace uniqueid = "40510218" if uniqueid == "504102118" & key == "uuid:ba4c24ab-b7fd-438b-b9b3-392852965f17"
replace reenter_studentid_202 = 40510218 if reenter_studentid_202 == 504102118 & key == "uuid:ba4c24ab-b7fd-438b-b9b3-392852965f17"

replace uniqueid = "40510216" if uniqueid == "504102116" & key == "uuid:7f58db43-6d54-4f26-99be-90e18c2f3bb8"
replace reenter_studentid_202 = 40510216 if reenter_studentid_202 == 504102116 & key == "uuid:7f58db43-6d54-4f26-99be-90e18c2f3bb8"

replace uniqueid = "4051024" if uniqueid == "50410214" & key == "uuid:7f965c2b-21c2-4f07-aea5-e25ae4f513aa"
replace reenter_studentid_202 = 4051024 if reenter_studentid_202 == 50410214 & key == "uuid:7f965c2b-21c2-4f07-aea5-e25ae4f513aa"

replace reenter_studentid_202 = 40510215 if reenter_studentid_202 == 504102115 & key == "uuid:5bce933b-4e17-4f33-9379-d712e99e9d84"
replace reenter_studentid_202 = 40510212 if reenter_studentid_202 == 504102112 & key == "uuid:6122c3db-1065-4cff-b789-51911ef5c414"

//Fixing the issue with studentid/uniqueid at GS Mukono as zerp was missing between 4-5 (the first two digits)
replace reenter_studentid_202 = 4051027 if reenter_studentid_202 == 451027 & key == "uuid:6a7b7c0b-461c-4a02-af87-524ea1da39b3"
replace reenter_studentid_202 = 40510217 if reenter_studentid_202 == 4510217 & key == "uuid:0ac8317d-0413-4596-991d-ebe62250a010"
replace reenter_studentid_202 = 40510218 if reenter_studentid_202 == 4510218 & key == "uuid:988ac628-4e81-4699-9f6f-d4ff220978f9"
replace reenter_studentid_202 = 40510210 if reenter_studentid_202 == 4510210 & key == "uuid:38f03104-380d-458e-90d5-907832f40221"
replace reenter_studentid_202 = 4051029 if reenter_studentid_202 == 4051029 & key == "uuid:647fc377-0954-45d2-9fca-5000f496fac8"
replace reenter_studentid_202 = 40510211 if reenter_studentid_202 == 4510211 & key == "uuid:327d9695-276e-4ff1-b64f-9c540d5746b0"
replace reenter_studentid_202 = 4051029 if reenter_studentid_202 == 451029 & key == "uuid:3cac4efe-3bc2-4146-adf4-9e616f686204"
replace reenter_studentid_202 = 4051021 if reenter_studentid_202 == 451021 & key == "uuid:1bcbd16d-2bad-46cd-9d74-246e740dde27"
replace reenter_studentid_202 = 40510215 if reenter_studentid_202 == 4510215 & key == "uuid:8ecaa302-f323-4815-8975-717d1d62d263"
replace reenter_studentid_202 = 40510214 if reenter_studentid_202 == 4510214 & key == "uuid:39c2d43d-edb7-4494-8c7b-139d0ca8437d"
replace reenter_studentid_202 = 40510212 if reenter_studentid_202 == 4510212 & key == "uuid:9c556a6c-8592-4c76-84cd-01d1b4d64b09"
replace reenter_studentid_202 = 40510219 if reenter_studentid_202 == 4510219 & key == "uuid:96ef9738-f532-40c9-97d1-5ad70ba827bf"
replace reenter_studentid_202 = 4051023 if reenter_studentid_202 == 451023 & key == "uuid:e20e4519-fec1-44aa-89d0-92144ed7f897"
replace reenter_studentid_202 = 4051028 if reenter_studentid_202 == 451028 & key == "uuid:b1539df0-b4d9-4ced-bcb5-19ebeaf0df3e"
replace reenter_studentid_202 = 4051025 if reenter_studentid_202 == 451025 & key == "uuid:1fa0d7de-0940-49b9-8178-041f0b2b1f6b"
replace reenter_studentid_202 = 40510216 if reenter_studentid_202 == 4510216 & key == "uuid:2b0db8a6-08ed-476a-8e1b-c1fd612e129e"

//Mariane Nakabonye was assigned to GS Mukono, yet she was enrolled at GS Jur at Baseline
replace group_107 = 2 if key == "uuid:647fc377-0954-45d2-9fca-5000f496fac8"
replace school_name = 45 if key == "uuid:647fc377-0954-45d2-9fca-5000f496fac8"
replace schoolid = 504102 if schoolid == 405102 & key == "uuid:647fc377-0954-45d2-9fca-5000f496fac8"
replace reenter_schoolid = 504102 if reenter_schoolid == 405102 & key == "uuid:647fc377-0954-45d2-9fca-5000f496fac8"

replace uniqueid = "040510217" if uniqueid  == "4510217" & key == "uuid:0ac8317d-0413-4596-991d-ebe62250a010"
replace uniqueid = "040510218" if uniqueid  == "4510218" & key == "uuid:988ac628-4e81-4699-9f6f-d4ff220978f9"
replace uniqueid = "040510219" if uniqueid  == "4510219" & key == "uuid:96ef9738-f532-40c9-97d1-5ad70ba827bf"
replace uniqueid = "040510216" if uniqueid  == "4510216" & key == "uuid:2b0db8a6-08ed-476a-8e1b-c1fd612e129e"



//Note: At ES Juru, at baseline, the schoolid was 507034 but all studentid(s) were created taking a reference to 705034 id
replace uniqueid = "70503417" if uniqueid == "50703417" & key == "uuid:ece37268-13d2-4629-9b8b-acbe991a44f5"
replace uniqueid = "70503419" if uniqueid == "50703419" & key == "uuid:d40483bc-e948-44eb-a230-f301a107c5c1"
replace uniqueid = "70503418" if uniqueid == "50703418" & key == "uuid:9067747e-99a2-4088-a262-441916a7beaa"
replace uniqueid = "70503420" if uniqueid == "50703420" & key == "uuid:9f492a63-fbc6-40d5-ad21-02bd41bb1c1c"
replace uniqueid = "70503416" if uniqueid == "50703416" & key == "uuid:01d34313-5932-441a-bd82-7fba64948f56"
replace uniqueid = "70503422" if uniqueid == "50703422" & key == "uuid:c3f2c7c3-22e9-417f-b115-a17017588cf3"
replace uniqueid = "70503421" if uniqueid == "50703421" & key == "uuid:275e31da-e080-4508-9976-6a0c8f7b4c7b"
 
replace reenter_studentid_202 = 70503417 if reenter_studentid_202 == 50703417 & key == "uuid:ece37268-13d2-4629-9b8b-acbe991a44f5"
replace reenter_studentid_202 = 70503419 if reenter_studentid_202 == 50703419 & key == "uuid:d40483bc-e948-44eb-a230-f301a107c5c1"
replace reenter_studentid_202 = 70503418 if reenter_studentid_202 == 50703418 & key == "uuid:9067747e-99a2-4088-a262-441916a7beaa"
replace reenter_studentid_202 = 70503420 if reenter_studentid_202 == 50703420 & key == "uuid:9f492a63-fbc6-40d5-ad21-02bd41bb1c1c"
replace reenter_studentid_202 = 70503416 if reenter_studentid_202 == 50703416 & key == "uuid:01d34313-5932-441a-bd82-7fba64948f56"
replace reenter_studentid_202 = 70503422 if reenter_studentid_202 == 50703422 & key == "uuid:c3f2c7c3-22e9-417f-b115-a17017588cf3"
replace reenter_studentid_202 = 70503421 if reenter_studentid_202 == 50703421 & key == "uuid:275e31da-e080-4508-9976-6a0c8f7b4c7b"
replace reenter_studentid_202 = 70503414 if reenter_studentid_202 == 50703414 & key == "uuid:163591d8-98ee-4fb2-bbd5-b5b95ffda96f"

//adding the entrepreneurship-general paper grades and student number-index number
 merge 1:1 key using "C:\Users\ANasabimana\Box Sync\IPA_RWA_Project_Educate\07_Questionnaires&Data\06 Endline_Quantitative\Data\Raw_data\entrepgpaper_gradedata.dta"
drop _merge

*save "student_endline_clean_final.dta", replace //former version as of 15 sept, 2019
save "student_endline_clean_final_ENTREP-GENPAPERADDED.dta", replace


/*
**useskills_708: Question restructured at endline
At endline this question was asked having 2 answer choices (Yes/No) only while in the word doc it was supposed to have the following answer choices:
708. If yes to 705, do you currently use this skill?
	Yes, for a group project/business that I am part of
	Yes, for my own project/business
	Yes, for someone else’s business
	No
	Other ____ 

*/

/*

*Questions rephrased at Endline

*@Baseline
. earn_500: 500_Do you currently earn money? Excluding pocket money

*@Endline
. earn_receive_401 : 401. In the past month, did you earn or receive money by working or from running a business?


*@Baseline
. amt_503 : 503_How much money did you personally earn from business and employment combined

*@Endline
howmuch_401.a  401. a How much have you earned in the last 2 months? Include all your sources of employment and business income? Write -99 if don’t know
*/

	local piivars locationlatitude locationlongitude locationaltitude locationaccuracy ///
	first_name_200 family_name_200 entr_teach_401 province district sector cell village ///
	mtn_pers_phone airtel_pers_phone tigo_pers_phone mtn_phone_moth_206 airtel_phone_moth_206 ///
	tigo_phone_moth_206 mtn_phone_fath_206 tigo_phone_fath_206 airtel_phone_fath_206 other_phone_206 ///
	mtn_phone_other_206 airtel_phone_other_206 tigo_phone_other_206 email_pers_207 email_other_207
	local piinum -99999
	local piistr NONPII VERSION
	generate piiid = _n
	ds `piivars', has(type numeric)
	foreach var in `r(varlist)' {
		replace `var' = `piinum' if !missing(`var')
	}
	ds `piivars', has(type string)
	foreach var in `r(varlist)' {
		replace `var' = "`piistr'" if !inlist(`var', "", "don't know", "refusal")
	}
	
*save "student_endline_clean_final_NOPIIs.dta", replace //former version as of 15 sept, 2019

save "student_endline_clean_final_ENTREP-GENPAPERADDED_NOPIIs.dta", replace

